package objects.test;

import objects.base.GravityObj;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.state.StateBasedGame;
import util.level.Room;


/**
 * A class that tests acceleration and has a
 * tendency to stack for use in testing collision.
 * 
 * @author John
 */

public class Hopper extends GravityObj
{
	/**
	 * Initializes a large bouncing test block at the given position.
	 * 
	 * @param initX - The initial X position.
	 * @param initY - The initial Y position.
	 */
	public Hopper(float initX, float initY)
	{
		super(initX, initY, 16, 16);
		yMotion[0].acc = 0.125f;
		pushPriority = 5;
	}

	/**
	 * Makes the block jump up and down.
	 * 
	 * @param gc {@inheritDoc}
	 * @param game {@inheritDoc}
	 */
	public void step(GameContainer gc,StateBasedGame sbg,Room room)
	{
		// Do movement
		super.step(gc,sbg,room);
		if (vertStop[1])
		{
			xMotion[0].speed = (float) ((Math.random()*12.5f)-6.25f);
			yMotion[0].speed = (float) -5.5;
		}
		// Stop the object when it hits the ceiling
		if (vertStop[0]) yMotion[0].speed = 0;
		if (horizStop[0] || horizStop[1])
		{
			xMotion[0].speed = -xMotion[0].speed;
		}
	}
}
